#pragma once
#include <vector>
#include <array>
#include "DataStructure/Common/SGNamespace.h"
#include "DataStructure/Common/Out.h"
#include "DataStructure/Common/Real.h"
#include "Utility/Algebra/Matrix.h"

SG_NAMESPACE_OPEN
namespace FEMSolver {
    namespace BeamElement {

        //截面单元几何属性结构体
        struct EleGeomProp 
        {
            SG::DataStructure::Common::Real Area;  
            SG::DataStructure::Common::Real Qy;    
            SG::DataStructure::Common::Real Qz;    
            SG::DataStructure::Common::Real Iy;    
            SG::DataStructure::Common::Real Iz;    
            SG::DataStructure::Common::Real Iyz;   
        };    
        
        class ISectionElement
        {
        public:
            virtual ~ISectionElement () = default;

            virtual void Initialize() = 0;   

            // 非翘曲属性计算（面积、静矩、惯性矩）
            virtual void CalculateGeomProp(const SG::Algebra::Matrixd& coord) = 0;
                        

            /**
             * @brief           计算单元矩阵（翘曲方程、剪切应力函数方程的刚度矩阵相同）
             *                  翘曲方程、剪切应力方程的刚度矩阵相同，但荷载不同，故 F 为3个Matrixd的vector
             * @param           coord         单元节点坐标
             * @param           inertiaMoment 截面的惯性矩数组，依次为[Iy Iz Iyz]
             * @param           mu            泊松比
             * @param[out]      Ke            刚度矩阵
             * @param[out]      F             荷载项（分为翘曲方程、剪切应力函数方程y向、z向3个荷载项）
             * @author   Liu Xing
             * @date     2025.10.17
             */
            virtual void ComputeEleMatrix
            (
            const SG::Algebra::Matrixd&                             coord,
            const std::array<SG::DataStructure::Common::Real ,3>&   inertiaMoment,
            const SG::DataStructure::Common::Real                   mu,
            _OUT  SG::Algebra::Matrixd&                             Ke,
            _OUT std::vector<SG::Algebra::Matrixd>&                 F
            ) const = 0;
            
            // 计算剪切系数计算式中对于单个单元的积分项
            virtual SG::Algebra::Matrixd ComputeShearCoeff
            (
            const SG::Algebra::Matrixd&                             coord,
            const std::array<SG::DataStructure::Common::Real ,3>&   inertiaMoment,
            const SG::DataStructure::Common::Real                   mu,
            const SG::Algebra::Matrixd&                             eleNodePsi,
            const SG::Algebra::Matrixd&                             eleNodePhi
            ) const = 0;

            // 计算单个单元的扇形积
            virtual SG::Algebra::Matrixd ComputeSectorProduct
            (
            const SG::Algebra::Matrixd& eleNodeCoord,
            const SG::Algebra::Matrixd& eleNodeOmega
            ) const = 0;
            
            // 获取单元几何属性
            virtual EleGeomProp GetGeomProp() const = 0;
        };

    };  // end namespace BeamElement
};  // end namespace FEMSolver
SG_NAMESPACE_CLOSE